home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / doRemoveConstraintTarget.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.0 KB  |  131 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Sept, 2002
  22. //  Author:         bb
  23. //
  24. //    Procedure Name:
  25. //        doRemoveConstraintTarget
  26. //
  27. //    Description:
  28. //      The user selects the target and the constrained object.
  29. //        This script removes the selected target from the constraint
  30. //        so that it no longer affects the object.
  31. //
  32. //    Input Arguments:
  33. //    $version: The version of this option box.  Used to know how to 
  34. //    interpret the $args array.
  35. //        "1" : first verison
  36. //  
  37. //    $args
  38. //    Version 1
  39. //    [0]        $which :  comma separated string of constraint types to affect, or "all" to remove the target from all existing constraint on the object
  40. //  [1]     $maintainOffset: whether to maintain the existing offset to the remaining targets
  41. //
  42. //    Return Value:
  43. //        none
  44. //
  45.  
  46.  
  47. global proc
  48. doRemoveConstraintTarget( string $version, string $args[] )
  49. {
  50.     string $sel[] = `ls -sl`;
  51.     if (size($sel) < 2) {
  52.         error("You must select one or more target(s) followed by the constrained object.");
  53.         return;
  54.     }
  55.  
  56.     string $cmd;
  57.     string $constrainedObj = $sel[size($sel)-1];
  58.  
  59.     int $maintainOffset = $args[1] ;
  60.     string $remFlag = " -remove;";
  61.     string $remMaintainOffsetFlag;
  62.     if ($maintainOffset) {
  63.         $remMaintainOffsetFlag = " -remove -maintainOffset; ";
  64.     } else {
  65.         $remMaintainOffsetFlag = " -remove; ";
  66.     }
  67.     
  68.     if ($args[0] == "all") {
  69.         string $p1 = `pointConstraint -q $constrainedObj`;
  70.         if (size($p1)) {
  71.             $cmd += "pointConstraint"+$remMaintainOffsetFlag;
  72.         }
  73.         string $a1 = `aimConstraint -q $constrainedObj`;
  74.         if (size($a1)) {
  75.             $cmd += "aimConstraint"+$remMaintainOffsetFlag;
  76.         }
  77.         string $o1 = `orientConstraint -q $constrainedObj`;
  78.         if (size($o1)) {
  79.             $cmd += "orientConstraint"+$remMaintainOffsetFlag;
  80.         }
  81.         string $s1 = `scaleConstraint -q $constrainedObj`;
  82.         if (size($s1)) {
  83.             $cmd += "scaleConstraint"+$remMaintainOffsetFlag;
  84.         }
  85.         string $par1 = `parentConstraint -q $constrainedObj`;
  86.         if (size($par1)) {
  87.             $cmd += "parentConstraint"+$remMaintainOffsetFlag;
  88.         }
  89.         string $g1 = `geometryConstraint -q $constrainedObj`;
  90.         if (size($g1)) {
  91.             $cmd += "geometryConstraint"+$remFlag;
  92.         }
  93.         string $t1 = `tangentConstraint -q $constrainedObj`;
  94.         if (size($t1)) {
  95.             $cmd += "tangentConstraint"+$remFlag;
  96.         }            
  97.         string $n1 = `normalConstraint -q $constrainedObj`;
  98.         if (size($n1)) {
  99.             $cmd += "normalConstraint"+$remFlag;
  100.         }
  101.         if (nodeType($constrainedObj) == "ikHandle") {
  102.             // the poleVectorConstraint is only valid on ikHandles
  103.             //
  104.             string $pv1 = `poleVectorConstraint -q $constrainedObj`;
  105.             if (size($pv1)) {
  106.                 $cmd += "poleVectorConstraint"+$remFlag;
  107.             }
  108.         }
  109.     } else {
  110.         string $buff[];
  111.         tokenize($args[0],",",$buff);
  112.         for ($constraint in $buff) {
  113.             if ($constraint == "poleVector" &&
  114.                 nodeType($constrainedObj) != "ikHandle") {
  115.                 // the poleVectorConstraint is only valid on ikHandles
  116.                 //
  117.                 continue;
  118.             }
  119.             $tmpCmd = ($constraint+"Constraint -q "+$constrainedObj);
  120.             string $ex = `eval $tmpCmd`;
  121.             if (size($ex)) {
  122.                 $cmd += ($constraint+"Constraint"+$remFlag);
  123.             }
  124.         }
  125.     }
  126.     if (size($cmd) == 0) {
  127.         error("A constrained object must be the last object selected.");
  128.     }
  129.     evalEcho $cmd;
  130. }
  131.